

#include "POSTest.h"

using namespace std;
CPPUNIT_TEST_SUITE_REGISTRATION (POSTest);

// Test Login() function
/*void POSTest::testLogin()
{
    cout << endl << "***Test 1)testLogin***" << endl;
    
    CPPUNIT_ASSERT_EQUAL(bookCtrl.Login("test1"),false); //wrong password
    CPPUNIT_ASSERT_EQUAL(bookCtrl.Login("assn1admin"),false); //test case sensitive
    CPPUNIT_ASSERT_EQUAL(bookCtrl.Login("Assn1Admin"),true); //correct password
        
    cout << "***Test 1)testLogin tested***" << endl << endl;
}*/

// Test AddRecord() function
/*void POSTest::testAddRecord()
{
    cout << endl << "***Test 2)testAddRecord***" << endl;
    //Pass
    BookingRecord Rec1("001","1","1","15/12/2014","0800","3","CSCI235","Bob","10");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec1),true);
    BookingRecord Rec2("003","20","2","15/09/2014","1300","3","CSCI204","Tim","80");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec2),true);
    BookingRecord Rec3("002","15","3","15/10/2014","1600","3","CSCI205","Mark","10");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec3),true);
    BookingRecord Rec4("004","13","4","18/10/2014","1300","3","CSCI206","Steve","100");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec4),true);
    
    //Fail - room number
    BookingRecord Rec5("003","21","2","15/07/2014","0800","3","CSCI222","John","20");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec5),false);
    //Fail - level number
    BookingRecord Rec6("003","2","6","15/07/2014","0800","3","CSCI222","John","30");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec6),false);
    //Fail - date format
    BookingRecord Rec7("003","2","2","15/15/2014","0800","3","CSCI222","John","30");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec7),false);
    //Fail - time format
    BookingRecord Rec8("003","2","2","15/08/2014","2500","3","CSCI222","John","30");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec8),false);
    //Fail - duration - max 5
    BookingRecord Rec9("003","2","2","15/09/2014","2000","10","CSCI222","John","30");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec9),false);
    //Fail - class size
    BookingRecord Rec10("003","10","2","25/09/2014","0800","1","CSCI222","John","90");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec10),false);
    //Fail - Room not available
    BookingRecord Rec10a("003","13","4","18/10/2014","1200","3","CSCI222","John","90");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec10a),false);
    
    //Pass
    BookingRecord Rec11("005","06","5","11/11/2014","1700","3","CSCI207","Bob","23");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec11),true);
    BookingRecord Rec12("006","18","2","11/11/2014","1300","3","CSCI208","Steve","56");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec12),true);
    BookingRecord Rec13("008","13","4","18/10/2014","0900","2","CSCI212","Mr Liu","30");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec13),true);
    BookingRecord Rec14("009","13","5","18/10/2014","1700","3","CSCI234","Mark","100");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec14),true);
    BookingRecord Rec15("007","11","4","18/10/2014","1500","1","CSCI256","Steve","100");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec15),true);
    BookingRecord Rec16("015","13","4","09/09/2014","1300","3","CSCI306","Steve","100");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec16),true);
    BookingRecord Rec17("012","13","4","08/09/2014","1800","3","CSCI206","John","100");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec17),true);
    BookingRecord Rec18("008","13","4","23/09/2014","1500","3","CSCI206","Steve","100");
    CPPUNIT_ASSERT_EQUAL(bookCtrl.AddRecord(Rec18),true);
    
    CPPUNIT_ASSERT_EQUAL(bookCtrl.SaveRecords("test_BookingRecords.txt"),true);
        
    cout << "***Test 2)testAddRecord tested***" << endl << endl;
}*/

// Test CancelRecord() function
/*void POSTest::testCancelRecord()
{
    cout << endl << "***Test 3)testCancelRecord***" << endl;
    
    CPPUNIT_ASSERT_EQUAL(bookCtrl.ReadRecords("test_BookingRecords.txt"),true);
    
    CPPUNIT_ASSERT_EQUAL(bookCtrl.CancelRecord("001"),true);
    CPPUNIT_ASSERT_EQUAL(bookCtrl.CancelRecord("999"),false);
    CPPUNIT_ASSERT_EQUAL(bookCtrl.CancelRecord("888"),false);
    CPPUNIT_ASSERT_EQUAL(bookCtrl.CancelRecord("004"),true);
    
    CPPUNIT_ASSERT_EQUAL(bookCtrl.SaveRecords("test_BookingRecords.txt"),true);
        
    cout << "***Test 3)testCancelRecord tested***" << endl << endl;
}*/

// Test testSearchAvailableRoom() function
// only date, time, duration and capacity required
/*void POSTest::testSearchAvailableRoom()
{
    cout << endl << "***Test4)testSearchAvailableRoom***" <<endl;
    
    CPPUNIT_ASSERT_EQUAL(bookCtrl.ReadRecords("test_BookingRecords.txt"),true);
    
    //No conflict with the existing booking records
    BookingRecord Rec1("001","1","1","15/08/2014","0800","3","CSCI235","Bob","10");
    bookCtrl.PrintRecord(Rec1,true);
    CPPUNIT_ASSERT_EQUAL(bookCtrl.SearchAvailableRoom(Rec1),100);
    
    //No conflict with the existing booking records
    BookingRecord Rec2("004","13","4","18/10/2014","1300","3","CSCI206","Steve","100");
    bookCtrl.PrintRecord(Rec2,true);
    CPPUNIT_ASSERT_EQUAL(bookCtrl.SearchAvailableRoom(Rec2),50);
    
    //Conflict with existing records.Room15 at level4 was booked.
    BookingRecord Rec3("003","15","3","15/10/2014","1600","3","CSCI205","Mark","10");
    bookCtrl.PrintRecord(Rec3,true);
    CPPUNIT_ASSERT_EQUAL(bookCtrl.SearchAvailableRoom(Rec3),99);
    
    //Conflict with existing records.Room20 at level2 was booked.
    BookingRecord Rec4("002","20","2","15/09/2014","1300","3","CSCI204","Tim","80");
    bookCtrl.PrintRecord(Rec4,true);
    CPPUNIT_ASSERT_EQUAL(bookCtrl.SearchAvailableRoom(Rec4),49);
        
    cout << "***Test4)testSearchAvailableRoom tested***" << endl << endl;
}*/

// Test Print Summary report - Daily, weekly and monthly
/*void POSTest::testSummaryReport()
{   
    cout << endl<<  "***Test 5)testSummaryReport***";
    ;
    CPPUNIT_ASSERT_EQUAL(bookCtrl.ReadRecords("test_BookingRecords.txt"),true);

    //Daily report
    CPPUNIT_ASSERT_EQUAL(bookCtrl.PrintDailyReport("11/11/2014",0),2);
    CPPUNIT_ASSERT_EQUAL(bookCtrl.PrintDailyReport("18/10/2014",1),3);
    CPPUNIT_ASSERT_EQUAL(bookCtrl.PrintDailyReport("15/01/2014",0),0);
    
    //Weekly Report
    CPPUNIT_ASSERT_EQUAL(bookCtrl.PrintWeeklyReport(37,1),2);
    CPPUNIT_ASSERT_EQUAL(bookCtrl.PrintWeeklyReport(42,1),4);
    CPPUNIT_ASSERT_EQUAL(bookCtrl.PrintWeeklyReport(25,0),0);
    
    //Monthly report
    CPPUNIT_ASSERT_EQUAL(bookCtrl.PrintMonthlyReport(11,1),2);
    CPPUNIT_ASSERT_EQUAL(bookCtrl.PrintMonthlyReport(9,0),4);
    CPPUNIT_ASSERT_EQUAL(bookCtrl.PrintMonthlyReport(3,0),0);
    
    //All records
    CPPUNIT_ASSERT_EQUAL(bookCtrl.PrintAllReport(0),10);
    CPPUNIT_ASSERT_EQUAL(bookCtrl.PrintAllReport(1),10);
    
    cout << "***Test 5)testSummaryReport tested***" << endl;
}*/







